/*
 * appSettings.java
 *
 * Created on 15. prosinec 2003, 10:26
 */

package cz.masa.FotoCAT;
import javax.swing.*;
/**
 *
 * @author  Administrator
 */
public class SettingsPanel extends javax.swing.JPanel {
    JInternalFrame parent_jif;
    boolean isInIFrame = false;
    
    /** Creates new form appSettings */
    public SettingsPanel() {
        initComponents();
        
        jTextFieldCDDrive.setText(FotoCAT.applicationProps.getProperty("CDDrive"));
        jTextFieldZipDrive.setText(FotoCAT.applicationProps.getProperty("ZipDrive"));
        jTextFieldTheme.setText(FotoCAT.applicationProps.getProperty("LookAndFeelTheme"));
        jTextFieldMagic.setText(FotoCAT.applicationProps.getProperty("ImageMagicDir"));
        jTextFieldCamera.setText(FotoCAT.applicationProps.getProperty("CestaFotak"));
        jTextFieldViewPic.setText(FotoCAT.applicationProps.getProperty("ViewerEXE_1"));
        jTextFieldViewVid.setText(FotoCAT.applicationProps.getProperty("ViewerEXE_2"));
        jTextFieldViewSnd.setText(FotoCAT.applicationProps.getProperty("ViewerEXE_3"));
        jTextFieldEditPic.setText(FotoCAT.applicationProps.getProperty("EditEXE_1"));
        
        int selind = 0;
        String selstr = FotoCAT.applicationProps.getProperty("LookAndFeel");
        if(selstr.compareTo("javax.swing.plaf.metal.MetalLookAndFeel") == 0) selind = 0;
        if(selstr.compareTo("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") == 0) selind = 1;
        if(selstr.compareTo("com.sun.java.swing.plaf.motif.MotifLookAndFeel") == 0) selind = 2;
        if(selstr.compareTo("com.l2fprod.gui.plaf.skin.SkinLookAndFeel") == 0) selind = 3;
        jComboBoxLFclass.setSelectedIndex(selind);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldCDDrive = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldZipDrive = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldCamera = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldMagic = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldViewPic = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldViewVid = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTextFieldViewSnd = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldEditPic = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jComboBoxLFclass = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldTheme = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jButtonCancel = new javax.swing.JButton();
        jButtonSave = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)));
        jLabel1.setText("CD drive");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.ipadx = 10;
        jPanel1.add(jLabel1, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        gridBagConstraints.weightx = 100.0;
        jPanel1.add(jTextFieldCDDrive, gridBagConstraints);

        jLabel4.setText("Zip drive");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel1.add(jLabel4, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jTextFieldZipDrive, gridBagConstraints);

        jLabel6.setText("IMagic dir");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel1.add(jLabel6, gridBagConstraints);

        jLabel5.setText(" ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        jPanel1.add(jLabel5, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jTextFieldCamera, gridBagConstraints);

        jLabel7.setText("Camera path");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel1.add(jLabel7, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel1.add(jTextFieldMagic, gridBagConstraints);

        jTabbedPane1.addTab("Main", jPanel1);

        jPanel4.setLayout(new java.awt.GridBagLayout());

        jPanel4.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)));
        jLabel8.setText("Viewer (picture)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.ipadx = 10;
        jPanel4.add(jLabel8, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        gridBagConstraints.weightx = 100.0;
        jPanel4.add(jTextFieldViewPic, gridBagConstraints);

        jLabel9.setText("Viewer (video)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel4.add(jLabel9, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel4.add(jTextFieldViewVid, gridBagConstraints);

        jLabel10.setText("Editor (picture)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel4.add(jLabel10, gridBagConstraints);

        jLabel11.setText(" ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        jPanel4.add(jLabel11, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel4.add(jTextFieldViewSnd, gridBagConstraints);

        jLabel12.setText("Viewer (sound)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel4.add(jLabel12, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel4.add(jTextFieldEditPic, gridBagConstraints);

        jTabbedPane1.addTab("External tools", jPanel4);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        jPanel2.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)));
        jLabel2.setText("L&F class");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel2.add(jLabel2, gridBagConstraints);

        jComboBoxLFclass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "javax.swing.plaf.metal.MetalLookAndFeel", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel", "com.sun.java.swing.plaf.motif.MotifLookAndFeel", "com.l2fprod.gui.plaf.skin.SkinLookAndFeel" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel2.add(jComboBoxLFclass, gridBagConstraints);

        jLabel3.setText("Theme");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
        jPanel2.add(jLabel3, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        jPanel2.add(jTextFieldTheme, gridBagConstraints);

        jTabbedPane1.addTab("Look & Feel", jPanel2);

        add(jTabbedPane1, java.awt.BorderLayout.CENTER);

        jButtonCancel.setText("Cancel");
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelActionPerformed(evt);
            }
        });

        jPanel3.add(jButtonCancel);

        jButtonSave.setText("Save");
        jButtonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveActionPerformed(evt);
            }
        });

        jPanel3.add(jButtonSave);

        add(jPanel3, java.awt.BorderLayout.SOUTH);

    }//GEN-END:initComponents

    private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
        // Add your handling code here:
        FotoCAT.applicationProps.setProperty("CDDrive",jTextFieldCDDrive.getText());
        FotoCAT.applicationProps.setProperty("LookAndFeel", (String)jComboBoxLFclass.getSelectedItem());
        FotoCAT.applicationProps.setProperty("LookAndFeelTheme",jTextFieldTheme.getText());
        FotoCAT.applicationProps.setProperty("ZipDrive",jTextFieldZipDrive.getText());
        FotoCAT.applicationProps.setProperty("ImageMagicDir",jTextFieldMagic.getText());
        FotoCAT.applicationProps.setProperty("CestaFotak",jTextFieldCamera.getText());   
        FotoCAT.applicationProps.setProperty("EditEXE_1",jTextFieldEditPic.getText());
        FotoCAT.applicationProps.setProperty("ViewerEXE_1",jTextFieldViewPic.getText());
        FotoCAT.applicationProps.setProperty("ViewerEXE_2",jTextFieldViewVid.getText());
        FotoCAT.applicationProps.setProperty("ViewerEXE_3",jTextFieldViewSnd.getText());
        if(isInIFrame) parent_jif.dispose();
    }//GEN-LAST:event_jButtonSaveActionPerformed

    private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
        // Add your handling code here:
        if(isInIFrame) parent_jif.dispose();
    }//GEN-LAST:event_jButtonCancelActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonSave;
    private javax.swing.JComboBox jComboBoxLFclass;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldCDDrive;
    private javax.swing.JTextField jTextFieldCamera;
    private javax.swing.JTextField jTextFieldEditPic;
    private javax.swing.JTextField jTextFieldMagic;
    private javax.swing.JTextField jTextFieldTheme;
    private javax.swing.JTextField jTextFieldViewPic;
    private javax.swing.JTextField jTextFieldViewSnd;
    private javax.swing.JTextField jTextFieldViewVid;
    private javax.swing.JTextField jTextFieldZipDrive;
    // End of variables declaration//GEN-END:variables

    public void setJInternalFrame(JInternalFrame jif){
        parent_jif = jif;
        isInIFrame = true;
    }    
    
    public static void openOnDesktop(){
        JInternalFrame frame = new JInternalFrame("Options",true,true,true,true);
        frame.setSize(460,270);
        frame.setLocation(20,20);
	SettingsPanel dpe = new SettingsPanel();
	dpe.setJInternalFrame(frame);
        frame.getContentPane().add(dpe);
        frame.setVisible(true);
        FotoCAT.desktop.add(frame);
	try {
            frame.setSelected(true);
	}
        catch (java.beans.PropertyVetoException e) {}
    }    
}
